package unsafeCollection;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @program: javase
 * @description:
 * @author: lld
 * @create: 2021-04-18 18:52
 **/
public class MapDemo {
    public static void main(String[] args) {
        HashMap<String, String> map1 = new HashMap<>();
        Map<String, String> map = Collections.synchronizedMap(map1);
        for (int i = 0; i < 200; i++) {
            new Thread(()->{
                map.put(UUID.randomUUID().toString().substring(0, 6)
                        , UUID.randomUUID().toString().substring(0, 6));
                System.out.println(map);
            }).start();
        }
    }
}
